﻿@model EmployeeIndexModel
@{
    var x = Html.X();
}
<script>
    function windowViewModel() {
        var self = this;
        self.selectThis = function(button) {

            var grid = button.ownerGrid || button.up("grid");
            var selected = grid.getSelectionModel().getSelection();
            if (selected.length < 1) {
                Tip("请选中一行。");
                return false;
            }
            var container = Ext.getCmp(grid.tag.controlId);
            if (container == null) {
                Tip("controlId不正确。");
                return false;
            }
            var textfield = container.down("textfield");
            textfield.setValue(selected[0].data.FullName);

            var hiddenContainer = container.down("hidden");
            hiddenContainer.setValue(selected[0].data.Id);

            App.Edit.CloseWindow(button);
            return true;
        }
    }
</script>
@(Html.X().Window()
                  .Width(700)
                  .Height(500)
                  .Icon(Icon.Clock).Layout(LayoutType.Fit)

                  .CloseAction(CloseAction.Destroy)
            .Items(x.GridPanel()
                .Tag(new
                {
                    ModuleId = Model.ModuleId,
                    controlId = Request.Form["controlId"]
                })
                .Store(x.StoreForModel().Proxy(
                x.AjaxProxy().ExtraParams(pp =>
                {
                })
                .Url(Url.Action("GetPaged")).Post().Reader(x.JsonReader().RootProperty("data"))).RemoteSort(true).RemotePaging(true).PageSize(25)
                .SorterFor(Model, m => m.Id, Ext.Net.SortDirection.DESC)
                )
                .SelectionModel(x.RowSelectionModel())
                .ColumnModel(
                    x.ColumnFor(m => m.Id),
                    x.ColumnFor(m => m.Code),
                    x.ColumnFor(m => m.FullName),
                    x.ColumnFor(m => m.GenderCode),
                    x.ColumnFor(m => m.Phone)
                            )
                .BottomBar(x.PagingToolbar())
                .EmptyText("无数据。")
                .View(x.GridView().StripeRows(true).TrackOver(true)).Listeners(ls =>
                {
                    ls.RowDblClick.Fn = "function(row){new windowViewModel().selectThis(row)}";
                })
         .Buttons(
                x.Button().Text("确定").OnClientClick("new windowViewModel().selectThis(this)"),
                x.Button().Text("关闭").OnClientClick("App.Edit.CloseWindow(this)"))
              )

)